package weekend02;

import java.io.File;
import java.io.FileFilter;

public class DeleteFileDemo {
    public static void main(String[] args) {
        for (int i = 1; i <= 10 ; i++) {
            File f =new File("demo"+i+".txt");
            if (f.exists()){
                f.delete();
            }else {
                System.out.println("未找到文件");
            }
        }
        System.out.println("删除完毕");

        File dir = new File(".");
        if (dir.isDirectory()){
            FileFilter filter =new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name = file.getName();
                    return name.endsWith("jpg");
                }
            };
            File[] subs = dir.listFiles(filter);
            for (File sub:subs){
                sub.delete();
            }
        }
    }
}
